package com.smartfast4j.common.component.fileManager.service;

import com.smartfast4j.common.component.fileManager.service.impl.FastdfsFileServiceImpl;
import com.smartfast4j.common.component.fileManager.service.impl.LocalFileServiceImpl;
import com.smartfast4j.common.component.fileManager.service.impl.SftpFileServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FileServiceConfig {

    private static final Logger LOG = LoggerFactory.getLogger(FileServiceConfig.class);

    @ConditionalOnProperty(value = "fileManager.type",havingValue = "SFTP")
    @Bean
    public FileService getSFtpInstance(){
        LOG.info("创建基于SFTP的FileService");
        return SftpFileServiceImpl.getInstance();
    }

    @ConditionalOnProperty(value = "fileManager.type",havingValue = "FastDFS")
    @Bean
    public FileService getFastDFSInstance(){
        LOG.info("创建基于Fastdfs的FileService");
        return FastdfsFileServiceImpl.getInstance();
    }
}
